var content = document.querySelector('.content');
var container = document.querySelector('.container');
var subBtn = document.getElementById('subBtn');

document.addEventListener("DOMContentLoaded", function() {

    $.ajax({
       url: '/management/teaservlet/teaSearchCourse',
       method: 'POST',
       success: function(response) {
         $('#drop').empty();
         var data = response.data;
         $.each(data, function(index, value) {
           var option = $('<option>').text(value);
           $('#drop').append(option);
         });
       },
       error: function(xhr, status, error) {
         console.log(error);
       }
    });

  var links = document.querySelectorAll('.sidebar ul li a');

  for (var i = 0; i < links.length; i++) {
    links[i].addEventListener('mouseenter', function() {
      this.style.transition = '0.2s';
      this.style.backgroundColor = '#679';
      this.style.borderRadius = '10px'; // 设置边缘的圆角半径为10px
    });

    links[i].addEventListener('mouseleave', function() {
      this.style.transition = '0.2s';
      this.style.backgroundColor = '';
      this.style.borderRadius = '10px'; // 鼠标移出时恢复原始边缘
    });
  }
});

content.addEventListener('mouseenter', function() {
     content.style.transition = 'background-color 0.3s';
     content.style.backgroundColor = 'rgba(100,100,100,0.5)'; // 将透明度更改为 0.5，使背景色加深
   });

content.addEventListener('mouseleave', function() {
     content.style.transition = 'background-color 0.3s';
     content.style.backgroundColor = 'rgba(100,100,100,0.2)'; // 将透明度恢复为 0.2，使背景色变浅
   });

subBtn.addEventListener('click', function() {

    var drop = document.getElementById("drop");  // 获取下拉列表元素
    var selectedValue = drop.value;  // 获取选中的值

    $.ajax({
           url: '/management/teaservlet/saveChooseCourse',
           method: 'POST',
           data: {
                selectedValue: selectedValue
           },
           success: function(response) {
//                var data1 = response.data;
//                console.log(data1);
              console.log(selectedValue);
              window.location.href = "inputGradeIn.html";
           },
           error: function(xhr, status, error) {
             console.log(error);
           }
        });
});